package org.infodavid.common.scheduler;

import org.infodavid.common.scheduler.commands.IScheduledCommand;
import org.infodavid.common.util.IVisitor;

/**
 * The Class VisitorStub.
 */
public class VisitorStub implements IVisitor<IScheduledCommand,Object> {

	/** The fired. */
	private static int fired = 0;

	/** The result. */
	@SuppressWarnings("unchecked")
  private static IResult<Object> result = IVisitor.SUCCESS;

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -1902630528681796596L;

	/**
	 * Gets fire count.
	 * @return the fire count
	 */
	public static int getFireCount() {
		return fired;
	}

	/**
	 * Gets the result.
	 * @return the result
	 */
	public static IResult<Object> getResult() {
		return result;
	}

	/**
	 * Sets the fired.
	 */
	public static void reset() {
		fired = 0;
	}

	/**
	 * Sets the result.
	 * @param value the new result
	 */
	public static void setResult(IResult<Object> value) {
		result = value;
	}

	/**
	 * Was fired.
	 * @return true, if successful
	 */
	public static boolean wasFired() {
		return fired > 0;
	}

	/**
	 * Instantiates a new sender stub.
	 */
	private VisitorStub() {
		super();
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.util.IVisitor#initialize()
	 */
	public void initialize() throws Exception {}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.util.IVisitor#visit(java.lang.Object)
	 */
	public IResult<Object> visit(IScheduledCommand data) throws Exception {
		synchronized (this) {
			fired++;
		}

		return result;
	}
}
